
var typess=1;
var typesss="";

var ss=0;
var ss2=0;
$(function(){
		ss=0;
		ss2=0;
		currentPage=1;
		currentPage2=1;
		$("#shangpingids").html("");
		$("#shangpingids2").html("");
	xianshu();
})

function jingr(tes,types){
		typess=types;
	if(tes==1){
		ss=0;
		ss2=0;
		currentPage=1;
		currentPage2=1;
		$("#shangpingids").html("");
		$("#shangpingids2").html("");
		xianshu();
	}else if(tes==2){
		ss=0;
		ss2=0;
		currentPage=1;
		currentPage2=1;
		$("#shangpingids").html("");
		$("#shangpingids2").html("");
		selectjingr();
	}
}


function xianshu(){
	    if(currentPage==0 || currentPage==1 || currentPage==2 || ss!=0){
		ss2=0;
		currentPage2=1;
		$("#shangpingids2").html("");
	    $.ajax({
        url:urlcore+"/api/rushGoods/selectRushGoodsList?current="+currentPage+"&type="+typess+"&timestatus=1",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var i=0;
					ss=data.data.list.length;
					  $.each(data.data.list,function(y,n){
					  	if(n.surplusstock!=n.rush_amount){
					  	i++;
					  	if(i==1){
					  $("#shijian").val(n.rush_time);
					  	}
			var shangpingids='<dl class="clearfix">'+
'        		<a href="4.0.1xianshiqianggou_detail.html?id='+n.goods_id+'&rudsid='+n.id+'">'+
'	        		<dt>'+
'	        			<img onerror="errorImg(this)" src="'+n.cover_url+'" />'+
'	        		</dt>'+
'	        		<dd>'+
'	        			<h5>'+n.goods_title+'</h5>'+
'	        			<span>已售出'+n.surplusstock+'件</span>'+
'	        			<div class="progress">'+
'							<div class="progress-bar" style="width: 85%; ">'+
'								'+
'							</div>'+
'							<div class="progress-value">'+n.surplusstock+'/'+n.rush_amount+'</div>'+
'						</div>'+
'						<div class="jg_price">'+
'							<h6>&nbsp;'+n.cheap_price+'<span>原价:'+n.pack_price+'</span></h6>'+
'							<em>立即抢购</em>'+
'						</div>'+
'	        		</dd>'+
'        		</a>'+
'        	</dl>';
					  	$("#shangpingids").append(shangpingids);
					  	}
					  });
					      $(function () {
       $('.jg_header li').on('click',function(){
            //给菜单添加选择样式
            $(this).addClass('jg_curr').siblings().removeClass('jg_curr');
             typesss=$(this).addClass('jg_curr').attr("id");
       });
    });
					 }
			},
			error: function() {
				alert("error");
			}
		});
			
	    }
		
}

var currentPage2=1;
var currentPage=1;
function selectjingr(){
		if(currentPage2==1 || currentPage2==2 || currentPage2==0 || ss2!=0){
		ss=0;
		currentPage=1;
		$("#shangpingids").html("");
	             	$.ajax({
        url:urlcore+"/api/rushGoods/selectRushGoodsList?current="+currentPage2+"&type="+typess+"&timestatus=0",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					var i=0;
					
					  $.each(data.data.list,function(y,n){
					  	i++;
					  	if(i==1){
					  		$("#shijian").val(n.rush_time);
					  	}
	        		var shangpingids='<dl class="clearfix">'+
	        		'<dt>'+
	        		'<a href="7.0.0goods_detail.html?id='+n.goods_id+'">'+
	        			'<img onerror="errorImg(this)" src="'+n.cover_url+'" />'+
	        		'</dt>'+
	        		'<dd>'+
	        			'<h5>'+n.goods_title+'</h5>'+
	        			'<span>'+n.trade_number+'件起批</span>'+
	        			'<span>&nbsp;</span>'+
	        		/*	<!--<div class="progress">
							<div class="progress-bar" style="width: 85%; ">
							</div>
							<div class="progress-value">85/100</div>
						</div>-->*/
						'<div class="jg_price" style="border: 1px solid #19b360;">'+
							'<h6 style="color: #19b360;">&nbsp;'+n.cheap_price+'<span>原价:'+n.trade_price+'</span></h6>'+
							'<em style="background: #19b360;" name="'+n.id+'" onclick="tixing(this)">提醒设置</em>'+
						'</div>'+
	        		'</dd>'+
        		'</a>'+
        	     '</dl>';
					  	$("#shangpingids2").append(shangpingids);
					  	
					  });
					      $(function () {
       $('.jg_header li').on('click',function(){
            //给菜单添加选择样式
            $(this).addClass('jg_curr').siblings().removeClass('jg_curr');
           typess=$(this).addClass('jg_curr').attr("id");
       });
    });
					 }
			},
			error: function() {
				alert("error");
			}
		});
			
		}
}


function tixing(te){
	 var  nameid=$(te).attr("name");
	 alert(nameid+"未接入")
	  /*  $.ajax({
        url:urlcore+"/api/rushGoods/flashsale?id="+nameid,
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					
				}
			},
			error: function() {
				alert("error");
			}
		});*/
}



//chaxunxiadan();
function chaxunxiadan(){
	 $.ajax({
        url:urlcore+"/api/message/scrollbar",
			type: "get",
			dataType: 'json',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
				if(data.success == true) {
					$.each(data.data, function(y,n) {
		var shijian='<div class="jg_xianshi_show">'+
			'<img src="'+n.user.headImg+'" />'+
	                     '<p>最新订单来自'+n.user.userName+'</p>'+
	                     '</div>';
	               $("#qiangdan").append(shijian);
					});
				}else{
					alert(data.msg);
				}
			},
			error: function() {
				alert("error");
			}
		});
}

